package com.wsoft.bpm.component.command;

import lombok.AllArgsConstructor;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.deploy.DeploymentCache;
import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
import org.activiti.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry;

/**
 * @author zhonglj
 * @date 2024-11-11 15:42
 **/
@AllArgsConstructor
public class GetProcessDefinitionCacheEntryCmd implements Command<ProcessDefinitionCacheEntry> {

    private String processDefinitionId;

    @Override
    public ProcessDefinitionCacheEntry execute(CommandContext commandContext) {
        ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
        DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager();
        DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache = deploymentManager.getProcessDefinitionCache();
        return processDefinitionCache.get(processDefinitionId);
    }
}
